using System;

namespace CSharp_1209.Library
{
    class Novel
    {
        private Book[] objBook;

        public Novel(int max)
        {
            objBook = new Book[max];
        }

        //public void setBook(int index, Book value)
        //{
        //    //Checks if the index specified is within the range
        //    if (index < 0 || index > objBook.Length)
        //    {
        //        Console.WriteLine("Invalid Index");
        //        return;
        //    }
        //    else
        //    {
        //        objBook[index] = value;
        //    }
        //}

        public Book this[int index]
        {
            get
            {
                //Checks if the index specified is within the range
                if (index < 0 || index > objBook.Length)
                {
                    return null;
                }
                else
                {
                    return objBook[index];
                }
            }
            set
            {
                //Checks if the index specified is within the range
                if (index < 0 || index > objBook.Length)
                {
                    Console.WriteLine("Invalid Index");
                    return;
                }
                else
                {
                    objBook[index] = value;
                }
            }
        }

        public void DisplayDetails()
        {
            Console.WriteLine("CATEGORY: NOVEL\n");
            Console.WriteLine("Book ID\t\tBook Name\t\tISBN Number");
            Console.WriteLine("-------\t\t---------\t\t-----------");
            for (int i = 0; i < objBook.Length; i++)
            {
                Console.WriteLine(objBook[i].BookID + "\t\t" + objBook[i].BookTitle + "\t\t" + objBook[i].IsbnNumber);
            }
        }
    }
}
